from global_values import gg
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *

class my1(QWidget):
    def __init__(self):
        super().__init__()        
    def closeEvent(self,e):
        a.quit()

class my5(QWidget):
    def __init__(self,ty):
        super().__init__()        
        self.ty = ty
        icon_g = QIcon('size3_rl.cur')     
        if ty==1:
            icon_g = QIcon('size4_rl.cur')     
        self.setWindowFlags(Qt.WindowStaysOnTopHint|Qt.FramelessWindowHint|Qt.ToolTip)
        mouse_cursor_size2 = self.mouse_cursor_size2 = 32
        self.mouse_cursor_pixmap2 = icon_g.pixmap(icon_g.actualSize(QSize(mouse_cursor_size2, mouse_cursor_size2)))
        t2 = QTimer(self)
        t2.timeout.connect(self.ont)
        t2.start(10)
        self.hide()
        self.status = (False,0,0)

    def paintEvent(self,e):                 
        p = QPainter(self) 
        ma = self.mouse_cursor_pixmap2.mask()                   
        self.setMask(ma)                             
        p.setRenderHint(QPainter.Antialiasing);        
        p.drawPixmap(0,0,self.mouse_cursor_size2,self.mouse_cursor_size2,self.mouse_cursor_pixmap2)
        return      
    
    def deal_chg(self):
        tt = gg.statusL[self.ty]
        ts = self.status
        if not tt[0]:
            if ts[0]:
                self.hide()
            return
        self.setGeometry(tt[1],tt[2],40,40)
        if not ts[0]:
            self.show()        

    def ont(self):
        if self.status == gg.statusL[self.ty]:
            return
        self.deal_chg()
        self.status = gg.statusL[self.ty]

import threading
from mouse_rec2 import work
t = threading.Thread(target=work)
t.daemon = True
t.start()
a = QApplication([])  

w = my5(0)
w3 = my5(1)
w2 = my1()
w2.show()
a.exec_()